<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./flexible.js"></script>
    <script src="./animate.js"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Swiper/5.x.x/css/swiper.min.css">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/Swiper/5.x.x/js/swiper.min.js"></script>
    <style>
        * {
            margin: 0%;
            padding: 0%;
        }

        .focus {
            margin: 0px auto;
            position: relative;
            width: 690px;
            height: 350px;
            background-color: #fff;
            overflow: hidden;
        }

        .focus ul {
            position: absolute;
            top: 0;
            left: 0;
            width: 500%;
            margin-left: -100%;
        }

        .focus ul li {
            float: left;
            width: 20%;
        }

        .circle {
            position: absolute;
            bottom: 10px;
            right: 50px;
        }

        .circle li {
            list-style: none;
            float: left;
            width: 8px;
            height: 8px;
            /* background-color: #fff; */
            border: 2px solid rgba(255, 255, 255, 0.5);
            margin: 0 3px;
            border-radius: 50%;
            /*鼠标经过显示小手*/
            cursor: pointer;
            transition: all .3s;
        }

        .focus ol li.current {
            width: 15px;
            background-color: #fff;
        }
    </style>
</head>

<body>
    <div class="focus">
        <!-- 放图片的盒子，要足够的大 -->
        <ul class="myul">
            <li>
                <a href="javascript:;"><img src="../1.jpg" alt=""></a>
            </li>
            <li>
                <a href="javascript:;"><img src="../2.jpg" alt=""></a>
            </li>
            <li>
                <a href="javascript:;"><img src="../3.jpg" alt=""></a>
            </li>
            <li>
                <a href="javascript:;"><img src="../4.jpg" alt=""></a>
            </li>
            <li>
                <a href="javascript:;"><img src="../5.jpg" alt=""></a>
            </li>
        </ul>
        <!-- 下面的小点点 -->
        <ol class="circle">
            <!-- 动态生成 -->
            <li class="current"></li>
            <!-- <li></li>
            <li></li> -->
        </ol>
    </div>
    <script>
        var myul = document.querySelector('.myul')
        var imgs = myul.querySelectorAll('li');
        var circle = document.querySelector('.circle')
        for (var i = 0; i < imgs.length; i++) {
            // 为图片设置索引,方便移动
            imgs[i].setAttribute('index', i);
            var li = document.createElement('li');
            circle.appendChild(li);

        }
        var lis = circle.querySelectorAll('li');
        for (var i = 0; i < lis.length; i++) {
            lis[i].addEventListener('click', function () {
                //点击获取焦点
                for (var j = 0; j < lis.length; j++) {
                    lis[j].className = '';
                }
                this.className = "current";

                // 点击移动图片
                animate(myul, 20);
            })
        }
    </script>
</body>

</html>